knitr::opts_chunk$set(echo = TRUE)
rm(list = ls())
most recent data Ayano shared
data <- read.csv("~/Rprojects/ayano/PES_010v6(selected).csv")
#colnames(data)
#time phase is tSSNA
units <- c("Speaker", "Role", "Phase")
codes_1 <- c("Functions", "Aesthetics", "User", "Vision", "Prototyping") # design actions codes
codes_2 <- c("CA", "ALoK", "CSU", "GCA", "Projective","Regulative","Relational") # shared epistemic agency codes
conversations = c("Role","Phase")
# hoo_rules <- conversation_rules(
# (TimePhase %in% UNIT$TimePhase & Role %in% UNIT$Role)
# )
notes: accum_1 and set_1 are for design action codes; accum_2 and set_2 are for shared epistemic agency codes
accum_1 = ena.accumulate.data(units = data[,units],
conversation = data[,conversations],
codes = data[,codes_1],
window.size.back = 4)
Note: Not doing means rotation so I can compare everything in the same space
set_1 = ena.make.set(accum_1)
accum_2 = ena.accumulate.data(units = data[,units],
conversation = data[,conversations],
codes = data[,codes_2],
window.size.back = 4)
set_2 = ena.make.set(accum_2)
Model 1: design action codes
Plot 1: Mean Network
plot = ena.plot(set_1, scale.to = "points", title = "Groups and Means") %>%
ena.plot.points(points = as.matrix(set_1$points)) %>%
ena.plot.group(point = as.matrix(set_1$points),
colors = c("black"), confidence.interval = "box") %>%
ena.plot.network(network = colMeans(as.matrix(set_1$line.weights)),colors = "black")
plot$plot
NA
Plot 2: All Means
#get list of time phases and groups loop over or use map function
phases = unique(set_1$points$Phase)
groups = unique(set_1$points$Role)
# col_list = list(pd = list("darkolivegreen2","darkolivegreen3","darkolivegreen4"),
# en = list("darkorange2","darkorange3","darkorange4"),
# sd = list("darkorchid1","darkorchid2","darkorchid3"))
col_list_2 = c("red",
"blue",
"green")
x = ena.plot(set_1, title = "Group Means by Phase")
for (i in 1:length(phases)){
for (j in 1:length(groups)){
points = set_1$points %>% filter(Phase == phases[i], Role == groups[j]) %>% as.matrix()
x = x %>%
ena.plot.group(points = points,
colors = col_list_2[i],
confidence.interval = "none",
labels = paste(phases[i],groups[j]))
}
}
x = x %>% ena.plot.network(network = colMeans(as.matrix(set_1$line.weights))*0,colors = "black")
x
NA
Stats:
reg_dat_design = set_1$points
mod_x_design = lm(SVD1 ~ as.factor(Phase) + Role, data = reg_dat_design)
mod_y_design = lm(SVD2 ~ as.factor(Phase) + Role, data = reg_dat_design)
summary(mod_x_design)
Call:
lm(formula = SVD1 ~ as.factor(Phase) + Role, data = reg_dat_design)
Residuals:
Min 1Q Median 3Q Max
-0.33875 -0.19734 0.00415 0.08239 0.83734
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.21470 0.10603 2.025 0.052504 .
as.factor(Phase)2 -0.46976 0.11548 -4.068 0.000350 ***
as.factor(Phase)3 -0.88394 0.11846 -7.462 3.98e-08 ***
RoleProductDesigner 0.06451 0.12087 0.534 0.597773
RoleServiceDesigner 0.51766 0.11846 4.370 0.000155 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.2762 on 28 degrees of freedom
Multiple R-squared: 0.7305, Adjusted R-squared: 0.692
F-statistic: 18.97 on 4 and 28 DF, p-value: 1.199e-07
summary(mod_y_design)
Call:
lm(formula = SVD2 ~ as.factor(Phase) + Role, data = reg_dat_design)
Residuals:
Min 1Q Median 3Q Max
-0.45072 -0.08698 0.03115 0.07065 0.31972
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.005242 0.064602 -0.081 0.93591
as.factor(Phase)2 -0.254687 0.070361 -3.620 0.00115 **
as.factor(Phase)3 -0.153102 0.072179 -2.121 0.04290 *
RoleProductDesigner 0.362531 0.073644 4.923 3.43e-05 ***
RoleServiceDesigner 0.043143 0.072179 0.598 0.55483
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.1683 on 28 degrees of freedom
Multiple R-squared: 0.6026, Adjusted R-squared: 0.5458
F-statistic: 10.61 on 4 and 28 DF, p-value: 2.313e-05
Marginal means - x
library(emmeans)
emm_x_design = emmeans(mod_x_design, specs = pairwise ~ Role|Phase, weights = "proportional")
emm_x_design = emmeans(mod_x_design, specs = pairwise ~ Phase|Role, weights = "proportional")
emm_x_design$contrasts
Role = Engineer:
contrast estimate SE df t.ratio p.value
Phase1 - Phase2 0.470 0.115 28 4.068 0.0010
Phase1 - Phase3 0.884 0.118 28 7.462 <.0001
Phase2 - Phase3 0.414 0.121 28 3.427 0.0053
Role = ProductDesigner:
contrast estimate SE df t.ratio p.value
Phase1 - Phase2 0.470 0.115 28 4.068 0.0010
Phase1 - Phase3 0.884 0.118 28 7.462 <.0001
Phase2 - Phase3 0.414 0.121 28 3.427 0.0053
Role = ServiceDesigner:
contrast estimate SE df t.ratio p.value
Phase1 - Phase2 0.470 0.115 28 4.068 0.0010
Phase1 - Phase3 0.884 0.118 28 7.462 <.0001
Phase2 - Phase3 0.414 0.121 28 3.427 0.0053
P value adjustment: tukey method for comparing a family of 3 estimates
Marginal means - y
emm_y_design = emmeans(mod_y_design, specs = pairwise ~ Role|Phase, weights = "proportional")
emm_y_design = emmeans(mod_y_design, specs = pairwise ~ Phase|Role, weights = "proportional")
emm_y_design$contrasts
Role = Engineer:
contrast estimate SE df t.ratio p.value
Phase1 - Phase2 0.255 0.0704 28 3.620 0.0032
Phase1 - Phase3 0.153 0.0722 28 2.121 0.1037
Phase2 - Phase3 -0.102 0.0736 28 -1.379 0.3650
Role = ProductDesigner:
contrast estimate SE df t.ratio p.value
Phase1 - Phase2 0.255 0.0704 28 3.620 0.0032
Phase1 - Phase3 0.153 0.0722 28 2.121 0.1037
Phase2 - Phase3 -0.102 0.0736 28 -1.379 0.3650
Role = ServiceDesigner:
contrast estimate SE df t.ratio p.value
Phase1 - Phase2 0.255 0.0704 28 3.620 0.0032
Phase1 - Phase3 0.153 0.0722 28 2.121 0.1037
Phase2 - Phase3 -0.102 0.0736 28 -1.379 0.3650
P value adjustment: tukey method for comparing a family of 3 estimates
Calculate eff sizes
Plot network subtractions for moderate to high eff sizes
mean1 = set_1$points %>% dplyr::filter(Phase == 1, Role == "Engineer")
mean2 = set_1$points %>% dplyr::filter(Phase == 1, Role == "ProductDesigner")
lw_1 = set_1$line.weights %>% dplyr::filter(Phase == 1, Role == "Engineer") %>% as.matrix() %>% colMeans()
lw_2 = set_1$line.weights %>% dplyr::filter(Phase == 1, Role == "ProductDesigner") %>% as.matrix() %>% colMeans()
plot = ena.plot(set_1, title = "Network Subtractions") %>%
ena.plot.points(points = mean1, colors = c("blue")) %>%
ena.plot.points(points = mean2, colors = c("red")) %>%
ena.plot.group(point = mean1, colors =c("blue"),
confidence.interval = "box") %>%
ena.plot.group(point = mean2, colors =c("red"),
confidence.interval = "box") %>%
ena.plot.network(network = lw_1 - lw_2, colors = c("blue","red"))
plot$plot
NA
Model 2: Epistemic Agency Codes
Plot 1: Mean Network
plot = ena.plot(set_2, scale.to = "points", title = "Groups and Means") %>%
ena.plot.points(points = as.matrix(set_2$points)) %>%
ena.plot.group(point = as.matrix(set_2$points),
colors = c("black"), confidence.interval = "box") %>%
ena.plot.network(network = colMeans(as.matrix(set_2$line.weights)),colors = "black")
plot$plot
NA
Plot 2: All Means
phases = unique(set_2$points$Phase)
groups = unique(set_2$points$Role)
# col_list = list(pd = list("darkolivegreen2","darkolivegreen3","darkolivegreen4"),
# en = list("darkorange2","darkorange3","darkorange4"),
# sd = list("darkorchid1","darkorchid2","darkorchid3"))
col_list_2 = c("red",
"blue",
"green")
x = ena.plot(set_2, title = "Group Means by Phase")
for (i in 1:length(phases)){
for (j in 1:length(groups)){
points = set_2$points %>% filter(Phase == phases[i], Role == groups[j]) %>% as.matrix()
x = x %>%
ena.plot.group(points = points,
colors = col_list_2[i],
confidence.interval = "none",
labels = paste(phases[i],groups[j]))
}
}
x = x %>% ena.plot.network(network = colMeans(as.matrix(set_2$line.weights))*0,colors = "black")
x
reg_dat_agency = set_2$points
mod_x_agency = lm(SVD1 ~ as.factor(Phase) + Role, data = reg_dat_agency)
mod_y_agency = lm(SVD2 ~ as.factor(Phase) + Role, data = reg_dat_agency)
summary(mod_x_agency)
Call:
lm(formula = SVD1 ~ as.factor(Phase) + Role, data = reg_dat_agency)
Residuals:
Min 1Q Median 3Q Max
-0.56585 -0.18405 -0.01777 0.20477 0.37706
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.2131 0.1018 -2.093 0.04553 *
as.factor(Phase)2 0.5169 0.1109 4.661 7.0e-05 ***
as.factor(Phase)3 0.8846 0.1138 7.776 1.8e-08 ***
RoleProductDesigner -0.3751 0.1161 -3.232 0.00314 **
RoleServiceDesigner -0.2811 0.1138 -2.471 0.01984 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.2653 on 28 degrees of freedom
Multiple R-squared: 0.72, Adjusted R-squared: 0.6801
F-statistic: 18 on 4 and 28 DF, p-value: 2.013e-07
summary(mod_y_agency)
Call:
lm(formula = SVD2 ~ as.factor(Phase) + Role, data = reg_dat_agency)
Residuals:
Min 1Q Median 3Q Max
-0.44439 -0.20784 0.00443 0.13841 0.64717
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.1997 0.1076 1.856 0.074047 .
as.factor(Phase)2 -0.2443 0.1172 -2.085 0.046353 *
as.factor(Phase)3 -0.1860 0.1202 -1.547 0.133174
RoleProductDesigner -0.4510 0.1227 -3.677 0.000993 ***
RoleServiceDesigner 0.2432 0.1202 2.023 0.052759 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.2803 on 28 degrees of freedom
Multiple R-squared: 0.5911, Adjusted R-squared: 0.5327
F-statistic: 10.12 on 4 and 28 DF, p-value: 3.39e-05
Marginal means - x
emm_x_agency1 = emmeans(mod_x_agency, specs = pairwise ~ Role|Phase, weights = "proportional")
emm_x_agency2 = emmeans(mod_x_agency, specs = pairwise ~ Phase|Role, weights = "proportional")
emm_x_agency1$contrasts
Phase = 1:
contrast estimate SE df t.ratio p.value
Engineer - ProductDesigner 0.3751 0.116 28 3.232 0.0085
Engineer - ServiceDesigner 0.2811 0.114 28 2.471 0.0504
ProductDesigner - ServiceDesigner -0.0941 0.111 28 -0.848 0.6768
Phase = 2:
contrast estimate SE df t.ratio p.value
Engineer - ProductDesigner 0.3751 0.116 28 3.232 0.0085
Engineer - ServiceDesigner 0.2811 0.114 28 2.471 0.0504
ProductDesigner - ServiceDesigner -0.0941 0.111 28 -0.848 0.6768
Phase = 3:
contrast estimate SE df t.ratio p.value
Engineer - ProductDesigner 0.3751 0.116 28 3.232 0.0085
Engineer - ServiceDesigner 0.2811 0.114 28 2.471 0.0504
ProductDesigner - ServiceDesigner -0.0941 0.111 28 -0.848 0.6768
P value adjustment: tukey method for comparing a family of 3 estimates
emm_x_agency2$contrasts
Role = Engineer:
contrast estimate SE df t.ratio p.value
Phase1 - Phase2 -0.517 0.111 28 -4.661 0.0002
Phase1 - Phase3 -0.885 0.114 28 -7.776 <.0001
Phase2 - Phase3 -0.368 0.116 28 -3.168 0.0100
Role = ProductDesigner:
contrast estimate SE df t.ratio p.value
Phase1 - Phase2 -0.517 0.111 28 -4.661 0.0002
Phase1 - Phase3 -0.885 0.114 28 -7.776 <.0001
Phase2 - Phase3 -0.368 0.116 28 -3.168 0.0100
Role = ServiceDesigner:
contrast estimate SE df t.ratio p.value
Phase1 - Phase2 -0.517 0.111 28 -4.661 0.0002
Phase1 - Phase3 -0.885 0.114 28 -7.776 <.0001
Phase2 - Phase3 -0.368 0.116 28 -3.168 0.0100
P value adjustment: tukey method for comparing a family of 3 estimates
Marginal means - y
emm_y_agency1 = emmeans(mod_y_agency, specs = pairwise ~ Role|Phase, weights = "proportional")
emm_y_agency2 = emmeans(mod_y_agency, specs = pairwise ~ Phase|Role, weights = "proportional")
emm_y_agency1$contrasts
Phase = 1:
contrast estimate SE df t.ratio p.value
Engineer - ProductDesigner 0.451 0.123 28 3.677 0.0028
Engineer - ServiceDesigner -0.243 0.120 28 -2.023 0.1254
ProductDesigner - ServiceDesigner -0.694 0.117 28 -5.923 <.0001
Phase = 2:
contrast estimate SE df t.ratio p.value
Engineer - ProductDesigner 0.451 0.123 28 3.677 0.0028
Engineer - ServiceDesigner -0.243 0.120 28 -2.023 0.1254
ProductDesigner - ServiceDesigner -0.694 0.117 28 -5.923 <.0001
Phase = 3:
contrast estimate SE df t.ratio p.value
Engineer - ProductDesigner 0.451 0.123 28 3.677 0.0028
Engineer - ServiceDesigner -0.243 0.120 28 -2.023 0.1254
ProductDesigner - ServiceDesigner -0.694 0.117 28 -5.923 <.0001
P value adjustment: tukey method for comparing a family of 3 estimates
emm_y_agency2$contrasts
Role = Engineer:
contrast estimate SE df t.ratio p.value
Phase1 - Phase2 0.2443 0.117 28 2.085 0.1113
Phase1 - Phase3 0.1860 0.120 28 1.547 0.2852
Phase2 - Phase3 -0.0584 0.123 28 -0.476 0.8832
Role = ProductDesigner:
contrast estimate SE df t.ratio p.value
Phase1 - Phase2 0.2443 0.117 28 2.085 0.1113
Phase1 - Phase3 0.1860 0.120 28 1.547 0.2852
Phase2 - Phase3 -0.0584 0.123 28 -0.476 0.8832
Role = ServiceDesigner:
contrast estimate SE df t.ratio p.value
Phase1 - Phase2 0.2443 0.117 28 2.085 0.1113
Phase1 - Phase3 0.1860 0.120 28 1.547 0.2852
Phase2 - Phase3 -0.0584 0.123 28 -0.476 0.8832
P value adjustment: tukey method for comparing a family of 3 estimates
Calculate eff sizes
Plot network subtractions for moderate to high eff sizes
mean1 = set_1$points %>% dplyr::filter(Phase == 1, Role == "Engineer")
mean2 = set_1$points %>% dplyr::filter(Phase == 1, Role == "ProductDesigner")
lw_1 = set_1$line.weights %>% dplyr::filter(Phase == 1, Role == "Engineer") %>% as.matrix() %>% colMeans()
lw_2 = set_1$line.weights %>% dplyr::filter(Phase == 1, Role == "ProductDesigner") %>% as.matrix() %>% colMeans()
plot = ena.plot(set_1, title = "Network Subtractions") %>%
ena.plot.points(points = mean1, colors = c("blue")) %>%
ena.plot.points(points = mean2, colors = c("red")) %>%
ena.plot.group(point = mean1, colors =c("blue"),
confidence.interval = "box") %>%
ena.plot.group(point = mean2, colors =c("red"),
confidence.interval = "box") %>%
ena.plot.network(network = lw_1 - lw_2, colors = c("blue","red"))
plot$plot